#include "stdio.h"
#include "malloc.h"
#include "string.h"
#include <iostream>
using namespace std;
typedef struct{
   int weight;
   int parent,lchild,rchild;
}HTNode,*HuffmanTree;
typedef char **HuffmanCode;

void Select(HuffmanTree HT,int n,int &s1,int &s2)
{
    int i,k1=1000000,k2=1000000;
    for(i=1;i<=n;i++)
    {
        if((HT[i].parent==0)&&(k1>HT[i].weight))
        {
            k1=HT[i].weight;
            s1=i;
        }
    }
    HT[s1].weight=1000000;
    for(i=1;i<=n;i++)
    {
        if((HT[i].parent==0)&&(k2>HT[i].weight))
        {
            k2=HT[i].weight;
            s2=i;
        }
    }
    HT[s1].weight=k1;
}

int CreateHuffmanTree(HuffmanTree &HT,int n)
{
    if(n<=1) return 0;
    int m,i,s1,s2;
    m=2*n-1;
    HT=new HTNode[m+1];
    for(i=1;i<=m;i++)
    {
        HT[i].lchild=0;HT[i].rchild=0;HT[i].parent=0;
    }
    for(i=1;i<=n;i++)
    {
        cin>>HT[i].weight;
    }
    for(i=n+1;i<=m;i++)
    {
       Select(HT,i-1,s1,s2);
       HT[s1].parent=i;
       HT[s2].parent=i;
       HT[i].lchild=s1;
       HT[i].rchild=s2;
       HT[i].weight=HT[s1].weight+HT[s2].weight;
    }
    return 1;
}

typedef char **HufffmanCode;
void CreatHuffamnCode(HuffmanTree HT,HufffmanCode &HC,int n)
{
    char *cd;
    int i,k,c,f;
    HC=new char*[n+1];
    cd=new char[n];
    cd[n-1]='\0';
    for(i=1;i<=n;i++)
    {
       k=n-1;
       c=i;
       f=HT[i].parent;
       while(f!=0)
       {
           k--;
           if(HT[f].lchild==c)
               cd[k]='0';
               else cd[k]='1';
               c=f;
               f=HT[f].parent;
       }
     HC[i]=new char[n-k];
     strcpy(HC[i],&cd[k]);
    }
    delete cd;

}
int main()
{
    int n,i;
    cin>>n;
    HufffmanCode HC;
    HuffmanTree HT;
    CreateHuffmanTree(HT,n);
    CreatHuffamnCode(HT,HC,n);
    for(i=1;i<=n;i++)
    {
        puts(HC[i]);
    }
}
